package com.bicon.botu.core.base.common.utils;


import java.util.Random;
import java.util.UUID;

public class IdGenerator {

    public static String createNewId() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    /*public static String createNewIdByPid(String pid,Integer order)
    {
        String count = String.valueOf(1000+order);
        String no = count.substring(1,count.length());
        pid = StringUtils.isBlank(pid)?"":pid;
        return pid+no;
    }*/
    public static String create24Id() {

        String id = UUID.randomUUID().toString().replaceAll("-", "");

        return id.substring(0, 24);

    }

    public static String create6Id() {

        String id = UUID.randomUUID().toString().replaceAll("-", "");

        return id.substring(0, 6);

    }
    public static String create7Id() {

        String id = UUID.randomUUID().toString().replaceAll("-", "");

        return id.substring(0, 6);

    }

    /**
     * 生成验证码
     *
     * @return
     */
    public static String createXCode(int x) {
        Random random = new Random();

        String result = "";

        for (int i = 0; i < x; i++) {

            result += random.nextInt(10);

        }

        return result;
    }


    public static String nickCreator(String account) {
        return account.substring(0, account.length() - (account.substring(3)).length()) + "****" + account.substring(7);
    }

    public static String createArrayId(int length) {
        String append[] = new String[]{"_0000", "_000", "_00", "_0", "_"};
        String new_str_id = String.valueOf(length + 1);
        new_str_id = append[new_str_id.length() - 1] + new_str_id;
        return new_str_id;
    }


    public static String createRandomId() {
        String append[] = new String[]{"_0000", "_000", "_00", "_0", "_"};
        int x;//定义变量
        Random ne = new Random();//实例化一个random的对象ne
        x = ne.nextInt(99999 - 10000 + 1);//为变量赋随机值0-99999
        String m = x + "";
        /*m = append[m.length() - 1] + m;
        System.out.println("产生的随机数是:" + m);//输出*/
        return append[m.length() - 1] + m;
    }
}



